package org.example.config;

import com.alibaba.druid.pool.DruidDataSource;
import org.example.dao.BookDao;
import org.example.dao.impl.BookDaoimpl;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


import javax.sql.DataSource;
@Configuration
public class jdbcconfig {
    @Value("com.mysql.cj.jdbc.Driver")
    private String driver;
    @Value("jdbc:mysql://localhost:3306/test")
    private String url;
    @Value("root")
    private String username;
    @Value("root")
    private String password;
    @Bean
    public DataSource ds(BookDao bookDao) {
        System.out.println(bookDao);
        DruidDataSource ds = new DruidDataSource();
        ds.setDriverClassName(driver);
        ds.setUrl(url);
        ds.setUsername(username);
        ds.setPassword(password);
        return ds;
    }
}